package cm.dayo7;



import java.util.ArrayList;
import java.util.Iterator;
import java.util.function.Consumer;

public class Test1 {
    public static void main(String[] args) {
        ArrayList<Integer> list=new ArrayList<>();
        list.add(11);
        list.add(12);
        list.add(15);
        list.add(21);
        list.add(17);
        //自增for循环遍历
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list);
        }
//增强for循环遍历
        list.forEach(new Consumer<Integer>() {
            @Override
            public void accept(Integer integer) {
                System.out.println(integer);
            }
        });
        //迭代器遍历
        Iterator<Integer> iterator=list.iterator();
        while (iterator.hasNext()) {
            Object obj = iterator.next();

            System.out.println(obj);
        }
    }
}
